package com.hupeng.serivce.impl;

import static org.junit.Assert.*;

import java.util.List;

import org.assertj.core.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.hupeng.domain.ProductCategory;
@RunWith(SpringRunner.class)
@SpringBootTest
public class CategoryServiceImplTest {
	@Autowired
	private CategoryServiceImpl categoryServiceImpl ;
	@Test
	public void testFindOne() {
		ProductCategory findOne = categoryServiceImpl.findOne(2);
		Assert.assertEquals(new Integer(2), findOne.getCategoryId());
		
	}

	@Test
	public void testFindAll() {
		List<ProductCategory> findAll = categoryServiceImpl.findAll();
		Assert.assertNotEquals(0, findAll.size());
	}

	@Test
	public void testFindByCategoryTypeIn() {
		List<Object> asList = Arrays.asList(new int[]{5,6,10});
		List<ProductCategory> findByCategoryTypeIn = categoryServiceImpl.findByCategoryTypeIn(asList);
		Assert.assertNotEquals(0, findByCategoryTypeIn.size());
	
	}

	@Test
	public void testSave() {
		ProductCategory productCategory = new ProductCategory("测试1", 13);
		ProductCategory save = categoryServiceImpl.save(productCategory);
				Assert.assertNotEquals(null, save);
	}

}
